import 'dart:convert';

class News {
  String id;
  String cmsId;
  String text;
  String title;
  String summary;
  String image;
  String source;
  DateTime inTime = DateTime.now();
  String timeStr;

  News(
      {this.id,
      this.cmsId = "",
      this.text = "",
      this.title = "",
      this.summary = "",
      this.source = "本站消息",
      this.image = "",
      this.inTime,
      this.timeStr = ""}) {
    if (this.inTime == null) this.inTime = DateTime.now();
  }

  factory News.fromJson(dynamic jsonObj) {
    return new News(
        id: jsonObj["Id"],
        cmsId: jsonObj["CmsId"],
        summary: jsonObj["Summary"],
        title: jsonObj["Title"],
        text: jsonObj["Text"],
        source: jsonObj["Source"],
        image: jsonObj["Img"],
        inTime: DateTime.parse(jsonObj["InTime"]));
  }
}
